
cc.Class({
    extends: cc.Component,

    properties: {
        display: cc.Sprite
    },

    start () {
        this._isShow = false;
        this.tex = new cc.Texture2D();
        //var openDataContext = wx.getOpenDataContext();
        //var sharedCanvas1 = openDataContext.canvas;
        if (sharedCanvas) {
        sharedCanvas.width = cc.game.canvas.width*2;
        sharedCanvas.height = cc.game.canvas.height*2;
        }
        //sharedCanvas.width = 720;
        
        //sharedCanvas.height = 1280;
        //let openDataContext = wx.getOpenDataContext();
        //let sharedCanvas1 = openDataContext.canvas;
        //cc.log('------------------》');

    },

    // use this for initialization
    onLoad: function () {
        
        /*
        this.display.node.on(cc.Node.EventType.TOUCH_END, function (event) {
            //cc.log('------------------》'+event.touch._point.x);
            //cc.log('------------------》'+event.touch._point.y);
            cc.log('------------------》');
        }, this.display);
        //this.display.on(cc.Node.EventType.TOUCH_END, function (event) {
        //}, this);*/
    },

    onClick () {
        cc.log('------------------》');
        this._isShow = !this._isShow;
        // 发消息给子域
        wx.postMessage({
            message: 'Show'
        })
    },

    _updaetSubDomainCanvas () {
        if (!this.tex) {
            return;
        }
        //cc.log('-----------》'+window.sharedCanvas.width+'-----'+window.sharedCanvas.height);
        //cc.log('-----------》');
        this.tex.initWithElement(sharedCanvas);
        this.tex.handleLoadedTexture();
        this.display.spriteFrame = new cc.SpriteFrame(this.tex);
    },

    update () {
        this._updaetSubDomainCanvas();
    }

});
